//
//  MHRouter.m
// MiaoCircle
//
//Created by acgera on 2018/4/9.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "MHRouter.h"


@interface MHRouter ()

/// viewModel到viewController的映射
@property (nonatomic, copy) NSDictionary *viewModelViewMappings;

@end

@implementation MHRouter

static MHRouter *sharedInstance_ = nil;

+ (id)allocWithZone:(struct _NSZone *)zone
{ 
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance_ = [super allocWithZone:zone];
    });
    return sharedInstance_;
}

- (id)copyWithZone:(NSZone *)zone
{
    return sharedInstance_;
}

+ (instancetype)sharedInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance_ = [[self alloc] init];
    });
    return sharedInstance_;
}

- (MHViewController *)viewControllerForViewModel:(MHViewModel *)viewModel {
    NSString *viewController = self.viewModelViewMappings[NSStringFromClass(viewModel.class)];
    
    NSParameterAssert([NSClassFromString(viewController) isSubclassOfClass:[MHViewController class]]);
    NSParameterAssert([NSClassFromString(viewController) instancesRespondToSelector:@selector(initWithViewModel:)]);
    
    return [[NSClassFromString(viewController) alloc] initWithViewModel:viewModel];
}


/// 这里是viewModel -> ViewController的映射
/// If You Use Push 、 Present 、 ResetRootViewController ,You Must Config This Dict
- (NSDictionary *)viewModelViewMappings {
    return @{
//             @"MHNewFeatureViewModel":@"MHNewFeatureViewController",
             @"MHLoginViewModel" : @"MHLoginViewController",
             @"MHSetCirclePropertyViewModel": @"MHSetPropertyOrTypeViewController",
             @"MHHomePageViewModel":@"MHHomePageViewController",
             @"MHSetCircleInfoViewModel":@"MHSettingCirleInfoViewController",
             @"MLCircleInfoMainPageViewModel": @"MLCircleInfoMainPageViewController",
             @"MHSetCirclePriceViewModel":@"MHSetCirclePriceViewController",
             @"MHSettingCircleViewModel":@"MHSettingCirleViewController",
             @"MHCircleManageViewModel":@"MHCircleManageViewController",
             @"MHSettingPublishPermissionViewModel":@"MHSettingPublishPermissionViewController",
             @"MHSettingCircleJoinTypeViewModel": @"MHSettingCircleJoinTypeViewController",
//             @"MHComposeViewModel":@"XFComposeViewController",
             @"MHComposeViewModel":@"MHComposeViewController",
             @"MHShareCircleViewModel":@"MHShareCircleViewController",
             @"MHAskViewModel":@"MHAskViewController",
             @"MHCircleMemberViewModel":@"MHCircleMemberViewController",
             @"MHBlackListViewModel":@"MHBlackListViewController",
             @"MHAuditListViewModel":@"MHAuditListViewController",
             @"MHEditMemberInfoViewModel":@"MHEditMemberInfoViewController",
             @"MHRepoViewModel":@"MHRepoViewController",
             @"MHSearchViewModel":@"MHSerchViewController",
             @"MHNewMemberViewModel":@"MHNewMemberViewController",
             @"MHAttributeTableViewModel":@"MHAttributeViewController",
             @"MHSearchMembersViewModel":@"MHSearchMembersViewController",
             @"MHMomentDetailViewModel":@"MHMomentDetailViewController",
             @"MHConversationListViewModel":@"ConversationListViewController",
//             @"MHChatViewModel":@"IMAChatViewController",
             @"MHChatViewModel":@"ChatViewController",
             @"MHUserHomeViewModel":@"UserHomePageController",
             @"MHRecentMessageViewModel":@"MHRecentMessageViewController",
             @"MHAuditInfoViewModel":@"MHAuditInfoViewController",
             @"MHUserInfoViewModel":@"MHUserInfoViewController",
             @"MHSettingViewModel":@"MHSettingViewController",
             @"MHShareAppViewModel":@"MHShareAppViewController",
             @"MHVideoRecordViewModel":@"TCVideoRecordViewController",
             @"MHVideoEditViewModel":@"TCVideoEditViewController",
             @"MHHelperViewModel":@"MHHelperViewController",
             @"MHFeedBackViewModel":@"MHFeedBackViewController",
             @"MHBindViewModel":@"MHBindPhoneViewController",
             @"MHBindSucessViewModel":@"MHBindSuccessViewController",
             @"MHSystemMessageViewModel":@"MHSystemMessageViewController",
             @"MHMyWalletViewModel":@"MHMyWalletViewController",
             @"MHInComeViewModel":@"MHPurseDetailViewController",
             @"MHTiXianViewModel":@"MHTiXianTableViewViewController",
             @"MHIdentityViewModel":@"MHIdentityConfigViewController",
             @"MHOderDetailViewModel":@"MHOrderDetailViewController",
             @"MHAboutUsViewModel":@"MHAboutViewController",
             @"MHAwemeListViewModel":@"AwemeListController",
             @"MHLocationViewModel":@"MHLocationViewController",
             @"MHDiscoverContainerViewModel":@"MHDiscoverContainerViewController",
             @"MHNearCollectionViewModel":@"MHNearByCollectionViewController",
             @"MHNearByHomeTableViewModel":@"MHNearByHomeCollectionViewController",
             @"MHBGMListViewModel":@"TCBGMListViewController",
             @"MHMusicCatergoryViewModel":@"MHMusicCatergoryTableViewController",
             @"MHCircleMoreViewModel":@"MHCirleMoreTableViewController",
             @"MHDetailLocationViewModel":@"MHDetailLocationViewController",
             @"MHRedPacketRecordViewModel":@"MHRedPacketRecordViewController",
             @"MHSettingRedPacketViewModel":@"MHSettingRedPacketViewController",
             @"MHRedPacketOrderViewModel":@"MHRedPacketOrderRecordViewController",
             @"MHRedPacketOrderContainerViewModel":@"MHRedPacketOrderContainerController",
             @"MHBindInvitedCodeViewModel":@"MHBindInvitedCodeViewController",
             @"MHProfileViewModel":@"MHProfileViewController",
//             @"MHMoreInfoViewModel":@"MHMoreInfoViewController",
//             @"MHFeatureSignatureViewModel":@"MHFeatureSignatureViewController",
//             @"MHAddFriendsViewModel":@"MHAddFriendsViewController",
//             @"MHSearchFriendsViewModel":@"MHSearchFriendsViewController",
//             @"MHAccountLoginViewModel":@"MHAccountLoginViewController",
//             @"MHBootLoginViewModel":@"MHBootLoginViewController",
//             @"MHLoginViewModel":@"MHLoginViewController",
//             @"MHMobileLoginViewModel":@"MHMobileLoginViewController",
//             @"MHZoneCodeViewModel":@"MHZoneCodeViewController",
        
             @"MHWebViewModel":@"MHWebViewController",
//             @"MHRegisterViewModel":@"MHRegisterViewController",
//             @"MHCommitViewModel":@"MHCommitViewController",
//             @"MHLanguageViewModel":@"MHLanguageViewController",
//             @"MHModifyNicknameViewModel":@"MHModifyNicknameViewController",
//             @"MHGenderViewModel":@"MHGenderViewController",
//             @"MHPlugViewModel":@"MHPlugViewController",
//             @"MHPlugDetailViewModel":@"MHPlugDetailViewController",
             @"MHAccountSecurityViewModel":@"MHAccountSecurityViewController",
             @"MHTestViewModel":@"MHTestViewController",
//             @"MHNotificationViewModel":@"MHNotificationViewController",
//             @"MHFreeInterruptionViewModel":@"MHFreeInterruptionViewController",
//             @"MHAboutUsViewModel":@"MHAboutUsViewController",
//             @"MHPrivacyViewModel":@"MHPrivacyViewController",
//             @"MHGeneralViewModel":@"MHGeneralViewController",
//             @"MHEmotionViewModel":@"MHEmotionViewController",
             @"MHMomentViewModel":@"MHMomentViewController",
             @"MHProfileInfoViewModel":@"MHProfileInfoViewController"
             };
}

@end
